<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:mo="https://gitee.com/aun/Timo">
<body>

    <form th:action="${#httpServletUtil.getRequest().getRequestURI()}" class="layui-card layui-form" data-auto="true" method="post" data-table-id="UserTable">

        <input type="hidden" name="id" th:if="${vo}" th:value="${vo.id}"/>

        <input type="hidden" name="companyId" th:value="${companyId}"/>

        <div class="layui-card-body">
            <fieldset class="layui-bg-gray">
                <legend><b class="layui-badge think-bg-violet">用户账号</b></legend>
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-xs2 text-center padding-top-15">
                        <input type="hidden" data-cut-width="500" data-cut-height="500" data-max-width="500" data-max-height="500" name="picture" th:value="${vo?.picture}">
                        <script>$('[name=picture]').uploadOneImageNew();</script>
                        <style>
                            .uploadimage, .uploadfile{
                                width: 78px!important;
                                height: 78px!important;
                            }
                        </style>
                    </div>
                    <div class="layui-col-xs5">
                        <label class="block relative">
                            <span class="help-label"><b>登录账号</b>User Name</span>
                            <input th:value="${vo?.username}" th:readonly="${vo?.id>0}" name="username" required vali-name="登录账号" placeholder="请输入登录账号" class="layui-input layui-bg-gray">
                            <span class="help-block">登录账号不能少于4位字符，创建后不能再次修改.</span>
                        </label>
                    </div>
                    <div class="layui-col-xs5">
                        <label class="block relative">
                            <span class="help-label"><b>用户名称</b>Nick Name</span>
                            <input name="nickname" th:value="${vo?.nickname}" th:readonly="${vo?.id>0}" required vali-name="用户名称" placeholder="请输入用户名称" class="layui-input layui-bg-gray">
                            <span class="help-block">用于区分用户数据的用户名称，请尽量不要重复.</span>
                        </label>
                    </div>
                </div>
            </fieldset>



            <fieldset class="layui-bg-gray" th:if="${roles}">
                <legend><b class="layui-badge think-bg-violet">用户权限</b></legend>
                <th:block th:if="${type!='-1'}">

                    <div class="layui-form-item">
                        <div class="help-label"><b>角色类型</b>Dep Permission</div>
                        <div class="layui-textarea help-checks">
                            <select name="type" class="layui-select" >
                                <option value="0" label="医院管理员" th:selected="${type == '0'}">医院管理员</option>
                                <option value="1" label="护士长" th:selected="${type == '1'}">护士长</option>
                                <option value="2" label="护理公司"   th:selected="${type == '2'}">护理公司</option>
                            </select>
<!--                            <input type="hidden" name="type" th:value="${type}">-->

                        </div>
                    </div>
                </th:block>
                <th:block th:if="${type=='-1'}">
                    <div class="layui-form-item">
                        <div class="help-label"><b>角色类型</b>Dep Permission</div>
                        <div class="layui-textarea help-checks">
                            <select name="type" class="layui-select">
                                <option value="0" label="医院管理员" th:selected="${vo != null && vo.type == '0'}">医院管理员</option>
                                <option value="1" label="护士长" th:selected="${vo != null && vo.type == '1'}">护士长</option>
                                <option value="2" label="护理公司"   th:selected="${vo != null && vo.type == '2'}">护理公司</option>
                            </select>
                        </div>
                    </div>
                </th:block>
                <div class="layui-form-item">
                    <div class="help-label"><b>访问权限</b>Role Permission</div>
                    <div class="layui-textarea help-checks">
                        <label class="think-checkbox" th:each="role:${roles}">
                            <input type="checkbox" name="roleId[]" th:value="${role.id}" lay-ignore th:checked="${auths.contains(role)}">
                            <th:block th:text="${role.title}"></th:block>
                        </label>

                    </div>
                </div>

                <th:block th:if="${type == '1' || (vo != null && vo.type =='-1')}">
                    <div class="layui-form-item">
                        <div class="help-label"><b>所属科室</b>Dep Permission</div>
                        <div class="layui-textarea help-checks">
                            <label class="think-checkbox" th:each="dep:${deps}">
<!--                                <input type="radio" name="depId" th:value="${dep.deptId}" lay-ignore th:checked="${dep.deptId==vo?.depId}">-->

                                <input type="radio" name="depId"
                                       th:value="${dep.deptId}"
                                       th:checked="${vo?.depId != null} and (${dep.deptId == vo?.depId})" lay-ignore>
                                <th:block th:text="${dep.name}"></th:block>
                            </label>

                        </div>
                    </div>
<!--                    <input type="hidden" name="type" th:value="${type}">-->

                </th:block>




            </fieldset>



            <fieldset class="layui-bg-gray">
                <legend><b class="layui-badge think-bg-violet">用户资料</b></legend>
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-xs6">
                        <label class="relative block">
                            <span class="help-label"><b>联系邮箱</b>Contact Email</span>
                            <input name="email" th:value="${vo?.email}" pattern="email" vali-name="联系邮箱" placeholder="请输入联系电子邮箱" class="layui-input">
                            <span class="color-desc">可选，请填写用户常用的电子邮箱</span>
                        </label>
                    </div>
                    <div class="layui-col-xs6">
                        <label class="relative block">
                            <span class="help-label"><b>联系手机</b>Contact Mobile</span>
                            <input type="tel" maxlength="11" name="phone" th:value="${vo?.phone}" pattern="phone" vali-name="联系手机" placeholder="请输入用户联系手机" class="layui-input">
                            <span class="color-desc">可选，请填写用户常用的联系手机号</span>
                        </label>
                    </div>

                </div>
                <label class="layui-form-item block relative margin-top-10">
                    <span class="help-label"><b>用户描述</b>User Remark</span>
                    <textarea placeholder="请输入用户描述" class="layui-textarea" name="remark">[[${vo?.remark}]]</textarea>
                </label>
            </fieldset>


            <div class="text-center layui-form-actions1">
                <button class="layui-btn" type="submit">保存</button>
                <button class="layui-btn layui-btn-danger" data-close data-confirm="确定要取消编辑吗？" type='button'>关闭</button>
            </div>

        </div>
    </form>


</body>
</html>